package com.qunar.toku.configuration;

import org.w3c.dom.Node;

import com.qunar.toku.TokuConst;
import com.qunar.toku.utility.TimeSpanHelper;


public class SocketPoolProfile {
	private int maxPoolSize;
	private boolean nagle;
	private boolean keepalive;
	private int waitTimeout;
	private int maxPakageSize;
	private int recvBufferSize;
	private int sendBufferSize;

	public SocketPoolProfile(Node node) {
	    this.maxPoolSize = Integer.parseInt(node.getAttributes().getNamedItem("maxPoolSize").getNodeValue());
	    this.nagle = Boolean.parseBoolean(node.getAttributes().getNamedItem("nagle").getNodeValue().toString());
	    this.keepalive = Boolean.parseBoolean(node.getAttributes().getNamedItem("keepalive").getNodeValue().toString());
	    this.waitTimeout = TimeSpanHelper.getIntFromTimeSpan(node.getAttributes().getNamedItem("waitTimeout").getNodeValue().toString());
		this.maxPakageSize = TokuConst.DEFAULT_MAX_PAKAGE_SIZE;
		this.recvBufferSize = TokuConst.DEFAULT_RECV_BUFFER_SIZE;
		this.sendBufferSize = TokuConst.DEFAULT_SEND_BUFFER_SIZE;
	}

	public int getMaxPoolSize() {
		return maxPoolSize;
	}

	public void setMaxPoolSize(int maxPoolSize) {
		this.maxPoolSize = maxPoolSize;
	}

	public boolean isNagle() {
		return nagle;
	}

	public void setNagle(boolean nagle) {
		this.nagle = nagle;
	}

	public boolean isKeepalive() {
		return keepalive;
	}

	public void setKeepalive(boolean keepalive) {
		this.keepalive = keepalive;
	}

	public int getWaitTimeout() {
		return waitTimeout;
	}

	public void setWaitTimeout(int waitTimeout) {
		this.waitTimeout = waitTimeout;
	}

	public int getMaxPakageSize() {
		return maxPakageSize;
	}

	public void setMaxPakageSize(int maxPakageSize) {
		this.maxPakageSize = maxPakageSize;
	}

	public int getRecvBufferSize() {
		return recvBufferSize;
	}

	public void setRecvBufferSize(int recvBufferSize) {
		this.recvBufferSize = recvBufferSize;
	}

	public int getSendBufferSize() {
		return sendBufferSize;
	}

	public void setSendBufferSize(int sendBufferSize) {
		this.sendBufferSize = sendBufferSize;
	}
	

}
